package com.zmn.mcc.services.impl.role;

import com.zmn.mcc.model.entity.role.McRoleModule;
import com.zmn.mcc.persistence.interfaces.role.RoleModuleDao;
import com.zmn.mcc.services.interfaces.role.RoleModuleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author heguanghua
 * @since 2020/04/14 21:37
 */
@Service
public class RoleModuleServiceImpl implements RoleModuleService {

    @Resource
    private RoleModuleDao roleModuleDao;


    @Override
    public McRoleModule findByKey(Integer roleId, Integer moduleId) {
        McRoleModule roleModule = new McRoleModule();
        roleModule.setRoleId(roleId);
        roleModule.setModuleId(moduleId);
        return this.findByKey(roleModule);
    }
    @Override
    public McRoleModule findByKey(McRoleModule roleModule) {
        return roleModuleDao.findByKey(roleModule);
    }

    @Override
    public List<Integer> listModuleIdByRoleId(Integer roleId) {
        return roleModuleDao.listModuleIdByRoleId(roleId);
    }

    @Override
    public List<Integer> listModuleIdByStaffId(Integer staffId) {
        return roleModuleDao.listModuleIdByStaffId(staffId);
    }

    @Override
    public Integer countByQuery(McRoleModule roleModule) {
        return roleModuleDao.countByQuery(roleModule);
    }



    @Override
    public Integer insert(McRoleModule roleModule) {
        return roleModuleDao.insert(roleModule);
    }
    
    @Override
    public Integer insertByBatch(List<McRoleModule> roleModulees) {
        return roleModuleDao.insertByBatch(roleModulees);
    }



    @Override
    public Integer deleteByKey(Integer roleId, Integer moduleId) {
        McRoleModule roleModule = new McRoleModule();
        roleModule.setRoleId(roleId);
        roleModule.setModuleId(moduleId);
        return this.deleteByKey(roleModule);
    }
    @Override
    public Integer deleteByKey(McRoleModule roleModule) {
        return roleModuleDao.deleteByKey(roleModule);
    }
    
    @Override
    public Integer deleteByRoleId(Integer roleId) {
        McRoleModule roleModule = new McRoleModule();
        roleModule.setRoleId(roleId);
        return this.deleteByQuery(roleModule);
    }
    @Override
    public Integer deleteByModuleId(Integer moduleId) {
        McRoleModule roleModule = new McRoleModule();
        roleModule.setModuleId(moduleId);
        return this.deleteByQuery(roleModule);
    }
    @Override
    public Integer deleteByQuery(McRoleModule roleModule) {
        return roleModuleDao.deleteByQuery(roleModule);
    }
}
